package com.mad.base.system;

public class Range2D<T>
{
    private IComparable2D<T> loVal, hiVal ;

    public IComparable2D<T> getLoVal()
    {
        return loVal;
    }

    private void setLoVal( IComparable2D<T> loVal )
    {
        this.loVal = loVal;
    }

    public IComparable2D<T> getHiVal()
    {
        return hiVal;
    }

    private void setHiVal( IComparable2D<T> hiVal )
    {
        this.hiVal = hiVal;
    } 
    
    public Range2D(IComparable2D<T> lo, IComparable2D<T> hi){
        this.setLoVal( lo ); 
        this.setHiVal( hi ); 
    }

    @SuppressWarnings( "unchecked" )
    public boolean isInRange( IComparable2D<T> toBeChecked )
    {   
        return this.loVal.smallerThanOrEqual( (T) toBeChecked ) && this.hiVal.greaterThanOrEqual( (T) toBeChecked ) && 
            this.hiVal.getComparableFirstDimension().compareTo( (T) toBeChecked.getComparableFirstDimension() ) >= 0 && 
            this.loVal.getComparableFirstDimension().compareTo( (T) toBeChecked.getComparableFirstDimension() ) <= 0; 
    }
    
    @Override
    public String toString(){
        return "range2D: "+this.loVal+", "+this.hiVal; 
    }
        
}
